//package com.authorization.authorizationserveronsso.security.handle;
//
//import com.alibaba.fastjson.JSON;
//import com.authorization.authorizationserveronsso.security.LoginUser;
//import com.authorization.authorizationserveronsso.security.service.TokenService;
//import com.authorization.authorizationserveronsso.utils.DataBus;
//import com.authorization.authorizationserveronsso.utils.HttpStatus;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.security.core.Authentication;
//import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
//
//@Configuration
//public class LogoutSuccessHandlerImpl implements LogoutSuccessHandler
//{
//    @Autowired
//    private TokenService tokenService;
//
//    /**
//     * 退出处理
//     *
//     * @return
//     */
//    @Override
//    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
//            throws IOException, ServletException
//    {
//        LoginUser loginUser = tokenService.getLoginUser(request);
//        if (loginUser != null)
//        {
//            String userName = loginUser.getUsername();
//            // 删除用户缓存记录
//            tokenService.delLoginUser(loginUser.getToken());
//            // 记录用户退出日志
//
//        }
//        try
//        {
//            response.setStatus(200);
//            response.setContentType("application/json");
//            response.setCharacterEncoding("utf-8");
//            response.getWriter().print(JSON.toJSONString(DataBus.success().data(String.valueOf(HttpStatus.SUCCESS), "退出成功")));
//        }
//        catch (IOException e)
//        {
//            e.printStackTrace();
//        }
//    }
//}
